//
//  UIBarButtonItem+InitWithCustomView.m
//  My_WeiBo
//
//  Created by Jay_Apple on 15/5/5.
//  Copyright (c) 2015年 Jay_Apple. All rights reserved.
//

#import "UIBarButtonItem+InitWithCustomView.h"

@implementation UIBarButtonItem (InitWithCustomView)


+ (UIBarButtonItem *)itemInitWithImage:(NSString *)imageName andHighlightImageName:(NSString *)highlightImageName Target:(id)target action:(SEL)selector{
    
    UIButton* btn = [[UIButton alloc] init];
    UIImage *bgImage = [UIImage imageNamed:imageName];
    [btn setBackgroundImage:bgImage forState:UIControlStateNormal];
    
    UIImage *hlImage = [UIImage imageNamed:highlightImageName];
    [btn setBackgroundImage:hlImage forState:UIControlStateHighlighted];
    
    [btn addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside];
    btn.My_Size = btn.currentBackgroundImage.size;
    
    UIBarButtonItem *barItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    
    return barItem;
    
}


@end
